package fasilkom.antz.gui;

import com.golden.gamedev.object.Sprite;

import fasilkom.antz.Antz;
import fasilkom.antz.GameChar;
import fasilkom.antz.WorldMap;


public class UnrecruitButton extends Button {

	WorldMap main;
	int order;
	
	public UnrecruitButton(WorldMap main, int order, int x, int y, int w, int h) {
		super("Release", x, y, w, h);
		this.main = main;
		this.order = order;
	}

	@Override
	public void doAction() {
		super.doAction();
		
		Antz parent = (Antz) main.parent;
		
		int i = 0;
		for (Sprite s : parent.PLAYER_GROUP.getSprites()) {
			if (s != null && s.isActive()) {
				if (i == order) {
					GameChar ant = (GameChar) s;
					ant.setActive(false);
					parent.antSaved += RecruitButton.antsNeeded[ant.status.level];
					break;
				}
				++i;
			}
		} 
		
		main.panelArmyRefresh();
	}
}
